package main;

import java.awt.Color;

import java.awt.Graphics2D;
import java.awt.Rectangle;


public class Drawer {
	public Drawer() {

	}
	
	public void draw(Graphics2D g2, Rectangle[][] rectangles, int[][] matrix) {

		for(int i = 0; i < matrix.length; i++)
		{
			for(int j = 0; j < matrix.length; j++)
			{
				boolean paint = true;
				if(matrix[i][j] == (int)Math.pow(matrix.length, 2))
					paint = false;
				if(paint){
					g2.setColor(Color.BLACK);
					g2.draw(rectangles[i][j]);	
					g2.setColor(Color.WHITE);
					g2.fill(rectangles[i][j]);
					
					if(matrix[i][j] % 2 == 0)
						g2.setColor(Color.BLUE);
					else
						g2.setColor(Color.RED);
					
					g2.drawString(Integer.toString(matrix[i][j]),(int)rectangles[i][j].getCenterX(), (int)rectangles[i][j].getCenterY());
				
				}
				else {
					g2.setColor(Color.DARK_GRAY);
					g2.draw(rectangles[i][j]);
					g2.fill(rectangles[i][j]);
				}

				
				
				
			}
		}
	}
}
